#include "cc_log.h"
#include "cc_core.h"
#include "cc_mempool.h"

#if (CC_CONFIG_TEST_SEM == 1)
cc_sem_t sem;
int test_sem_create()
{
  sem = cc_sem_create(0, 30);
  return 1;
}
CC_INIT_BOARD_REGISTER(test_sem_create);

void t1_sem(void* data)
{
  while (1)
  {
    cc_log("t1 wait\r\n");
    cc_sem_wait(sem);
    cc_log("t1 success\r\n");
    cc_delay(1000);
  }
}
CC_THREAD_REGISTER(t1_sem, 10, 2048);

void t2_sem(void* data)
{
  while (1)
  {
    cc_log("t2 wait\r\n");
    cc_sem_wait(sem);
    cc_log("t2 success\r\n");
    cc_delay(1000);
  }
}
CC_THREAD_REGISTER(t2_sem, 10, 2048);

void t3_sem(void* data)
{
  while (1)
  {
    cc_delay(5000);
    cc_sem_release(sem);
    cc_log("t3 release\r\n");
  }
}
CC_THREAD_REGISTER(t3_sem, 10, 2048);
#endif
